package o;

import android.os.Handler;
import java.util.Iterator;
import java.util.concurrent.CopyOnWriteArrayList;

public final class amu<T> {
    private final CopyOnWriteArrayList<c<T>> ˊ = new CopyOnWriteArrayList();

    public interface a<T> {
        void ˋ(T t);
    }

    static final class c<T> {
        private boolean ˊ;
        private final Handler ˎ;
        private final T ˏ;

        public c(Handler handler, T t) {
            this.ˎ = handler;
            this.ˏ = t;
        }

        public void ॱ() {
            this.ˊ = true;
        }

        public void ˎ(a<T> aVar) {
            this.ˎ.post(new amy(this, aVar));
        }

        private /* synthetic */ void ˏ(a aVar) {
            if (!this.ˊ) {
                aVar.ˋ(this.ˏ);
            }
        }
    }

    public void ˏ(Handler handler, T t) {
        boolean z = (handler == null || t == null) ? false : true;
        amm.ˊ(z);
        ˋ(t);
        this.ˊ.add(new c(handler, t));
    }

    public void ˋ(T t) {
        Iterator it = this.ˊ.iterator();
        while (it.hasNext()) {
            c cVar = (c) it.next();
            if (cVar.ˏ == t) {
                cVar.ॱ();
                this.ˊ.remove(cVar);
            }
        }
    }

    public void ˊ(a<T> aVar) {
        Iterator it = this.ˊ.iterator();
        while (it.hasNext()) {
            ((c) it.next()).ˎ(aVar);
        }
    }
}
